package com.config;

import com.util.CodeMsg;
import com.util.Result;
import org.apache.tomcat.util.http.fileupload.FileUploadBase;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartException;

@ControllerAdvice
public class BaseController {
 
 
    @ResponseBody
    @ExceptionHandler(value = FileUploadBase.FileSizeLimitExceededException.class)
    public Object fileUploadExceptionHandler(FileUploadBase.FileSizeLimitExceededException exception){

        return Result.error(CodeMsg.messageprop.getProperty("500400"));
    }

    @ResponseBody
    @ExceptionHandler(value = ServiceException.class)
    public Object ServiceExceptionHandler(ServiceException exception){

        return Result.error(CodeMsg.messageprop.getProperty(exception.getMessage()));
    }
}